package com.leyou.page.config;
import com.aliyun.dysmsapi20170525.Client;
import com.leyou.sms.config.SmsProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.aliyun.teaopenapi.models.Config;
/**
 * 初始化短信API的对象
 */
@Configuration
public class SmsConfig {
    @Bean
    public Client createClient(SmsProperties smsProperties)throws Exception{
        Config config = new Config()
                .setAccessKeyId(smsProperties.getAccessKeyID())
                .setAccessKeySecret(smsProperties.getAccessKeySecret());
        config.endpoint = smsProperties.getEndpoint();

        return new Client(config);
    }
}
